<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" placeholder="请输入要添加的用户名" id="">
    <input type="text" placeholder="请输入要添加的content" id="">
    <button>点击添加</button>

    <script>
        let inp = document.querySelectorAll('input')
        let btn = document.querySelector('button')

        btn.onclick = function () {
            let xhr = new XMLHttpRequest()
            xhr.open('post', 'http://wish.byesame.com/wish')
            xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded')
            xhr.setRequestHeader('token', localStorage.getItem('token'))
            xhr.send(`name=${inp[0].value}&content=${inp[1].value}&role=3`)
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4) {
                    let data = JSON.parse(xhr.responseText)
                    console.log(data);
                }
            }
        }

    </script>

</body>

</html>